﻿Public Class Autorizaciones
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        seguridad.verificapermisos()
    End Sub

    Protected Sub ASPxButton1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ASPxButton1.Click

        Dim em As Integer = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("empresasid"))
        Dim depto As Integer = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("departamentoid"))
        Dim userid As Integer = seguridad.usuarioid1
        Dim tabladetalleuser As New DataSet1TableAdapters.detalleusuarioTableAdapter
        Dim tablasolicitud As New DataSet1TableAdapters.solicitudesTableAdapter
        Dim solictiudid As Integer = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("solicitudid"))

        Dim permiso As Integer = tabladetalleuser.ScalarQuerySaberSIesJefedeXDepartamentoyEmpresa(userid, depto, em)
        ' tabladetalleuser.ScalarQuerySaberSIesJefedeXDepartamentoyEmpresa(5, depto, em)

        If permiso = 1 Then
            tablasolicitud.UpdateQueryPermiso("Autorizado", solictiudid)
            ASPxGridView1.DataBind()
        Else
            MsgBox("No tiene autorizacion para procesar solicitudes de otros departamentos", MsgBoxStyle.Information)
        End If
    End Sub

    Protected Sub ASPxButton4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ASPxButton4.Click
         Dim em As Integer = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("empresasid"))
       Dim depto As Integer = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("departamentoid"))
        Dim userid As Integer = seguridad.usuarioid1
        Dim tabladetalleuser As New DataSet1TableAdapters.detalleusuarioTableAdapter
        Dim tablasolicitud As New DataSet1TableAdapters.solicitudesTableAdapter
        Dim solictiudid As Integer = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("solicitudid"))

        Dim permiso As Integer = tabladetalleuser.ScalarQuerySaberSIesJefedeXDepartamentoyEmpresa(userid, depto, em)
        ' tabladetalleuser.ScalarQuerySaberSIesJefedeXDepartamentoyEmpresa(5, depto, em)

        If permiso = 1 Then
            tablasolicitud.UpdateQueryPermiso("Denegado", solictiudid)
            ASPxGridView1.DataBind()
        Else
            MsgBox("No tiene autorizacion para procesar solicitudes de otros departamentos", MsgBoxStyle.Information)
        End If
    End Sub
End Class